package com.doordu.soa.service.data.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.doordu.soa.service.data.dao.ParkingCompanyMapper;
import com.doordu.soa.service.data.entity.ParkingCompany;
import com.doordu.soa.service.data.entity.example.ParkingCompanyExample;
import com.doordu.soa.service.data.service.ParkingCompanyService;
import com.doordu.soa.service.data.vo.ParkingCompanyVo;
/**
 * 停车场公司服务实现类
 * @ClassName: ParkingCompanyServiceImpl
 * @Description: 
 * @author xiaoqun.yi yixq@doordu.com  
 * @date 2017年8月31日 下午1:39:39
 * @version V1.0
 */
@Service
public class ParkingCompanyServiceImpl implements ParkingCompanyService {

	@Autowired
	private ParkingCompanyMapper parkingCompanyMapper;

	@Override
	public ParkingCompanyVo selectByAppIdAndAppSecret(String appId, String appSecret) {
		if (StringUtils.isBlank(appId) || StringUtils.isBlank(appSecret)) {
			return null;
		}
		ParkingCompanyExample example = new ParkingCompanyExample();
		ParkingCompanyExample.Criteria criteria = example.createCriteria();
		criteria.andAppIdEqualTo(appId);
		criteria.andAppSecretEqualTo(appSecret);
		List<ParkingCompany> result = parkingCompanyMapper.selectByExample(example);
		if (null == result || result.size() == 0) {
			return null;
		}
		ParkingCompanyVo parkingCompanyVo = new ParkingCompanyVo();
		BeanUtils.copyProperties(result.get(0), parkingCompanyVo);
		return parkingCompanyVo;
	}

}
